<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* 行高实现文字居中 */
    /* .father {
      width:300px;
      height:300px;
      line-height:300px;
      text-align:center;
      background-color: pink
    } */
    /* flex实现文字居中 */
    /* .father {
      display:flex;
      width: 300px;
      height: 300px;
      align-items: center;
      justify-content:center;
      background-color: pink
    } */
    /* table-cell实现居中 */
    .father {
      display: table-cell;
      width: 300px;
      height: 300px;
      text-align:center;
      vertical-align:middle;
      background-color: pink
    }
  </style>
</head>

<body>
  <div class="father">span</div>
</body>

</html>